﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HCMServices.DAO;
using HCMServices.DTO;
using System.Collections.Generic;

namespace HCMServices.Tests.TESTDAO
{
    /// <summary>
    /// Unit test for WardDAO class
    /// </summary>
    [TestClass]
    public class TestWardDAO
    {
        /// <summary>
        /// Unit test for Search() method in WardDAO class
        /// </summary>
        [TestMethod]
        public void TestSearch()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            WardDAO wardDAO = new WardDAO(connectString);
            WardDTO wardDTO = null;
            wardDTO = wardDAO.Search(170);
            if (wardDTO != null && wardDTO.Id == 170 && wardDTO.Name == "Bến Nghé")
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }

        /// <summary>
        /// Unit test for GetAllPhuongDTO() method in WardDAO class
        /// </summary>
        [TestMethod]
        public void TestGetAllPhuongDTO()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            WardDAO wardDao = new WardDAO(connectString);
            List<WardDTO> listWardDTO = null;
            listWardDTO = wardDao.GetAllPhuongDTO();
            if (listWardDTO == null || listWardDTO.Count == 0)
            {
                Assert.IsFalse(true);
            }

            foreach (WardDTO ward in listWardDTO)
            {
                if (ward.Name == "11")
                {
                    if (ward.Id != 138)
                    {
                        Assert.IsFalse(true);
                    }
                }
            }

            Assert.IsTrue(true);
        }

        /// <summary>
        /// Unit test for TestGetIdByName() method in WardDAO class
        /// </summary>
        [TestMethod]
        public void TestGetIdByName()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            WardDAO wardDao = new WardDAO(connectString);
            int id = wardDao.GetIdByName("11");
            if (id == 138)
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }    
    }
}
